#ifndef TCP_TCPCONNECTION_H
#define TCP_TCPCONNECTION_H

#include <memory>
#include "TcpServer.h"

class TcpConnection;
typedef std::shared_ptr<TcpConnection> TcpConnectionPtr;

class TcpConnection{
public:
    void setConnectionCallback(const ConnectionCallback &connectionCallback){
        connectionCallback_ = connectionCallback;
    }

    void setMessageCallback(const MessageCallback &messageCallback){
        messageCallback_ = messageCallback;
    }

private:
    enum StateE{kConnecting, kConnected};
    // 状态枚举值

    void setState(StateE s){
        state_ = s;
    }

    void handleRead();

    std::string name_;
    // 连接名称
    StateE state_;
    // 当前连接状态
    int socket_;
    // 连接的socket;
    ConnectionCallback connectionCallback_;
    MessageCallback messageCallback_;
};

#endif //TCP_TCPCONNECTION_H
